package com.example.springbootsfzy.controller.lishenao;

import com.example.springbootsfzy.domain.ConsultantCertificates;
import com.example.springbootsfzy.service.lishenao.Consultant_certificatesService;
import com.example.springbootsfzy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//咨询师证书表
//操作人员:李深奥
//操作步骤:增删改查
@RestController
@CrossOrigin
public class Consultant_certificatesController {
    @Autowired
    private Consultant_certificatesService consultant_certificatesService;
    //根据咨询师id查询咨询师证书
    @GetMapping("selectcertificatebyconsultantid")
    public R selectByConsultantId( Long consultantId){
        return R.ok(consultant_certificatesService.selectByConsultantId(consultantId));
    }
    //添加咨询师证书
    @PostMapping("insertcertificate")
    public R insert(@RequestBody ConsultantCertificates consultantCertificates){
        int i = consultant_certificatesService.insert(consultantCertificates);
        if(i>0){
            return R.ok("添加成功");
        }else{
            return R.error("添加失败");
        }
    }
    //更新咨询师证书
    @PostMapping("updatecertificate")
    public R update(@RequestBody ConsultantCertificates consultantCertificates){
        int i = consultant_certificatesService.update(consultantCertificates);
        if(i>0){
            return R.ok("更新成功");
        }else{
            return R.error("更新失败");
        }
    }
    //删除咨询师证书
    @GetMapping("deletecertificate")
    public R delete(Long id){
        int i = consultant_certificatesService.delete(id);
        if(i>0){
            return R.ok("删除成功");
        }else{
            return R.error("删除失败");
        }
    }
}
